Introduction

You have already cloned the GitHub repository to a local repository named Capstone-project in your machine's workspace directory.

You have also created a Swift project with the name littlelemon . Inside it, you created a Swift app named Restaurant .

In this exercise, you’ll take the next step and commit the project to the remote repository on GitHub.

Scenario

You've established the framework for developing a food-ordering app by setting up a SwiftUI project for Little Lemon and cloning a repository. Let’s practice the procedure for committing a project to the remote repository, as this is something you’ll do regularly over the course of the project.

Prerequisites

You have set up a repository on GitHub and cloned it into the workspace directory. You should already have created a Swift project called littlelemon with an app named Restaurant in it.

Instructions

Step 1: Create a new branch in the local repository

Open the terminal and use the command git checkout –B command<branch-name> to create a new git branch.

Tip : Anywhere you see a text between the <> arrows, it means that you must substitute your own text there. For example, <branch-name> should be substituted with your chosen name of the branch like exercise_branch .

Step 2: Add the project folder to the stage

In the Git terminal, enter the command git add .

Step 3: Check the status

In the Git terminal, enter the command git status . This will display a list of details about the commit.

Step 4: Commit the changes

The Git command for this action is:

git commit –m "message"

Step 5: Push the changes to the GitHub repository

Use the command:

gitpush –u original <branch-name>

Step 6: Log in to GitHub and open the repository

The repository page should display the Compare & pull request button. Go ahead and press it.

Step 7: Create a pull request

On the repository page, you’ll see the changes committed, and the Create & pull request button .

You will then be taken to the view which will ask you which branch you want to merge and where.

Select main on the left-hand side and the branch you want to merge code from on the right (for example, exercise_branch ).

After that, press the green button named Create pull request below.

Step 8: Merge pull request

Review the changes and confirm by pressing the Merge pull request button .

Step 9: Log in to the main branch of local repository

Go back to the Git terminal and enter the following command:

git checkout main

Step 10: Update the main branch

Use the git pull command.

Conclusion

In this exercise, you practiced the steps to push the Swift project files to the GitHub repository.